package io.output;

import org.junit.Test;

import java.io.*;

/**
 * @author mubei
 * @date 2021/12/3
 * @description
 */
public class BufferReaderWriterCopy_ {

    @Test()
    public void test1() {
        // 
        String source = "D:\\date\\distable\\practice\\code\\basic\\src\\main\\java\\io\\test.txt";
        String target = "D:\\date\\distable\\practice\\code\\basic\\src\\main\\java\\io\\ah.txt";
        BufferedReader reader = null;
        BufferedWriter writer = null;
        try {
            reader = new BufferedReader(new FileReader(source));
            writer = new BufferedWriter(new FileWriter(target));
            String s;
            while((s = reader.readLine() )!=null){
                writer.write(s);
                writer.newLine();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {

            try {
                reader.close();
                writer.close();
            } catch (Exception e) {
                e.printStackTrace();
            }

        }

    }
}
